package org.zfes.snowier.cloud.zbss.cms.router.service.template;

import java.util.Map;
import java.util.Optional;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.cloud.zbss.cms.template.model.CmsTemplate;
import org.zfes.snowier.cloud.zbss.cms.template.service.ICmsTemplateService;
@Controller 
@RequestMapping("/cms/template/cmsTemplate")
public class CmsTemplateController extends BaseController {

	
	@Autowired
	private ICmsTemplateService cmsTemplateService;
	
	@RequiresPermissions(value="cmsTemplate:loadCmsTemplateDataSet",desc="模版列表")
    @RequestMapping(value="/loadCmsTemplateDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadCmsTemplateDataSet(@RequestParam Map<String,Object> params){
	    DataSet dataSet=  cmsTemplateService.loadCmsTemplateDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
	
	@RequiresPermissions(value="cmsTemplate:createCmsTemplate",desc="模版添加")
    @RequestMapping(value="/createCmsTemplate", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public  @ResponseBody Object createCmsTemplate(CmsTemplate cmsTemplate){
		cmsTemplateService.createCmsTemplate(cmsTemplate);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
	@RequiresPermissions(value="cmsTemplate:loadCmsTemplate",desc="模版加载")
    @RequestMapping(value="/loadCmsTemplate", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadCmsTemplate(Long id){
		Optional<CmsTemplate> ops = cmsTemplateService.loadCmsTemplateById(id);
		return ajaxQuery("cmsTemplate",ops);
    }
	
	@RequiresPermissions(value="cmsTemplate:updateCmsTemplate",desc="模版更新")
    @RequestMapping(value="/updateCmsTemplate", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object updateCmsTemplate(CmsTemplate cmsTemplate){
		cmsTemplateService.updateCmsTemplate(cmsTemplate);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
	@RequiresPermissions(value="cmsTemplate:deletCmsTemplate",desc="模版删除")
    @RequestMapping(value="/deleteCmsTemplate", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object deleteCmsTemplate(Long id){
		cmsTemplateService.deleteCmsTemplate(id);
		return ajaxDoneSuccess("数据操作成功 ");
    }

}